clear
rng default

%% Part 1 (Early)

%%%%%%%%  True and Logit %%%%%%%%
%%% Load
load Table1_R1
load Table1_R2
%%% Fill
tab_temp1=fill_function_Gumbel(Phi_Gumbel_early);

%%%%%%%%  SpecA %%%%%%%%
tab_temp2=fill_function(Phi_early_R1);

%%%%%%%%  SpecB %%%%%%%%
tab_temp3=fill_function(Phi_early_R2);


%%%%%%% Combine %%%%%%%%
tab_part1=cell(12,4);
tab_part1(1,:)=tab_temp1(1,:);
tab_part1(2,:)=tab_temp2(1,:);
tab_part1(3,:)=tab_temp3(1,:);
tab_part1(4,:)=tab_temp1(2,:);
tab_part1(5,:)=tab_temp2(2,:);
tab_part1(6,:)=tab_temp3(2,:);
tab_part1(7,:)=tab_temp1(3,:);
tab_part1(8,:)=tab_temp2(3,:);
tab_part1(9,:)=tab_temp3(3,:);
tab_part1(10,:)=tab_temp1(4,:);
tab_part1(11,:)=tab_temp2(4,:);
tab_part1(12,:)=tab_temp3(4,:);
    

%%%%%%% Generate Latex table %%%%%%%%
n_digits=2;
for i=1:12
    for j=1:4
        tab_part1{i,j}= round(tab_part1{i,j},n_digits);
        tab_part1{i,j}=mat2str(tab_part1{i,j});
    end
end
matrix2latex(tab_part1,'tab1.tex','alignment', 'c', 'format', '%1.1f', 'size', 'tiny');



%% Part 2 (Late)

%%%%%%%%  True and Logit %%%%%%%%
%%% Fill
tab_temp1=fill_function_Gumbel(Phi_Gumbel_late);

%%%%%%%%  SpecA %%%%%%%%
tab_temp2=fill_function(Phi_late_R1);

%%%%%%%%  SpecB %%%%%%%%
tab_temp3=fill_function(Phi_late_R2);


%%%%%%% Combine %%%%%%%%
tab_part2=cell(12,4);
tab_part2(1,:)=tab_temp1(1,:);
tab_part2(2,:)=tab_temp2(1,:);
tab_part2(3,:)=tab_temp3(1,:);
tab_part2(4,:)=tab_temp1(2,:);
tab_part2(5,:)=tab_temp2(2,:);
tab_part2(6,:)=tab_temp3(2,:);
tab_part2(7,:)=tab_temp1(3,:);
tab_part2(8,:)=tab_temp2(3,:);
tab_part2(9,:)=tab_temp3(3,:);
tab_part2(10,:)=tab_temp1(4,:);
tab_part2(11,:)=tab_temp2(4,:);
tab_part2(12,:)=tab_temp3(4,:);
    

%%%%%%% Generate Latex table %%%%%%%%
n_digits=2;
for i=1:12
    for j=1:4
        tab_part2{i,j}= round(tab_part2{i,j},n_digits);
        tab_part2{i,j}=mat2str(tab_part2{i,j});
    end
end
matrix2latex(tab_part2,'tab2.tex','alignment', 'c', 'format', '%1.1f', 'size', 'tiny');



%% Part 3 (Diff)

%%%%%%%%  True and Logit %%%%%%%%
%%% Fill
tab_temp1=fill_function_Gumbel(Delta_Gumbel_Phi);

%%%%%%%%  SpecA %%%%%%%%
tab_temp2=fill_function(Delta_Phi_R1);

%%%%%%%%  SpecB %%%%%%%%
tab_temp3=fill_function(Delta_Phi_R2);


%%%%%%% Combine %%%%%%%%
tab_part3=cell(12,4);
tab_part3(1,:)=tab_temp1(1,:);
tab_part3(2,:)=tab_temp2(1,:);
tab_part3(3,:)=tab_temp3(1,:);
tab_part3(4,:)=tab_temp1(2,:);
tab_part3(5,:)=tab_temp2(2,:);
tab_part3(6,:)=tab_temp3(2,:);
tab_part3(7,:)=tab_temp1(3,:);
tab_part3(8,:)=tab_temp2(3,:);
tab_part3(9,:)=tab_temp3(3,:);
tab_part3(10,:)=tab_temp1(4,:);
tab_part3(11,:)=tab_temp2(4,:);
tab_part3(12,:)=tab_temp3(4,:);
    

%%%%%%% Generate Latex table %%%%%%%%
n_digits=2;
for i=1:12
    for j=1:4
        tab_part3{i,j}= round(tab_part3{i,j},n_digits);
        tab_part3{i,j}=mat2str(tab_part3{i,j});
    end
end
matrix2latex(tab_part3,'tab3.tex','alignment', 'c', 'format', '%1.1f', 'size', 'tiny');



